{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/components/ContactControl/index.tsx\",\n  _s = $RefreshSig$();\nimport React from 'react';\nimport { observer } from \"mobx-react-lite\";\nimport { Context } from \"../../index\";\nimport { findContactOrReturnNull } from \"../../utils/Contact\";\nimport { Modal } from \"../index\";\nimport './ContactControl.scss';\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nimport { Fragment as _Fragment } from \"react/jsx-dev-runtime\";\nconst ContactControl = props => {\n  _s();\n  const {\n    store\n  } = React.useContext(Context);\n  const [findContactWithIndex, setFindContactWithIndex] = React.useState();\n  const [showModalOnAll, setShowModalOnAll] = React.useState(false);\n  React.useEffect(() => {\n    if (!props.selfProfile && store.getProfile().id !== props.profile.id) {\n      setFindContactWithIndex({\n        ...findContactWithIndex,\n        ...findContactOrReturnNull(props.profile, store.getProfile(), store.getContacts())\n      });\n    }\n  }, [store.getContacts(), props.profile]);\n  if (!props.selfProfile && store.getProfile().id !== props.profile.id) {\n    if ((findContactWithIndex === null || findContactWithIndex === void 0 ? void 0 : findContactWithIndex.contact) === null) {\n      return /*#__PURE__*/_jsxDEV(\"div\", {\n        className: \"contact__control\",\n        children: /*#__PURE__*/_jsxDEV(\"button\", {\n          children: \"\\u0414\\u043E\\u0431\\u0430\\u0432\\u0438\\u0442\\u044C \\u0432 \\u043A\\u043E\\u043D\\u0442\\u0430\\u043A\\u0442\\u044B\"\n        }, void 0, false, {\n          fileName: _jsxFileName,\n          lineNumber: 30,\n          columnNumber: 21\n        }, this)\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 29,\n        columnNumber: 17\n      }, this);\n    } else if (findContactWithIndex !== null && findContactWithIndex !== void 0 && findContactWithIndex.contact && findContactWithIndex !== null && findContactWithIndex !== void 0 && findContactWithIndex.index) {\n      if (findContactWithIndex.contact.status) {\n        return /*#__PURE__*/_jsxDEV(\"div\", {\n          className: \"contact__control\",\n          children: [/*#__PURE__*/_jsxDEV(\"span\", {\n            children: \"\\u0423 \\u0432\\u0430\\u0441 \\u0432 \\u043A\\u043E\\u043D\\u0442\\u0430\\u043A\\u0442\\u0430\\u0445\"\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 37,\n            columnNumber: 25\n          }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n            children: \"\\u0423\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u043A\\u043E\\u043D\\u0442\\u0430\\u043A\\u0442\"\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 38,\n            columnNumber: 25\n          }, this)]\n        }, void 0, true, {\n          fileName: _jsxFileName,\n          lineNumber: 36,\n          columnNumber: 21\n        }, this);\n      } else {\n        return /*#__PURE__*/_jsxDEV(\"div\", {\n          className: \"contact__control\",\n          children: [findContactWithIndex.contact.fromUser.id === props.profile.id && /*#__PURE__*/_jsxDEV(\"span\", {\n            children: \"\\u0417\\u0430\\u044F\\u0432\\u043A\\u0430 \\u043E\\u0442\\u043F\\u0440\\u0430\\u0432\\u043B\\u0435\\u043D\\u0430\"\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 45,\n            columnNumber: 29\n          }, this), findContactWithIndex.contact.toUser.id === props.profile.id && /*#__PURE__*/_jsxDEV(\"button\", {\n            children: \"\\u041F\\u0440\\u0438\\u043D\\u044F\\u0442\\u044C \\u0437\\u0430\\u044F\\u0432\\u043A\\u0443\"\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 48,\n            columnNumber: 29\n          }, this), /*#__PURE__*/_jsxDEV(\"button\", {\n            children: \"\\u0423\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u0437\\u0430\\u044F\\u0432\\u043A\\u0443\"\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 50,\n            columnNumber: 25\n          }, this), /*#__PURE__*/_jsxDEV(Modal, {\n            active: showModalOnAll,\n            title: \"Удаление заявки\",\n            hasFunctionButtons: true,\n            onSubmit: () => {\n              store.deleteContactFromAPI(findContactWithIndex === null || findContactWithIndex === void 0 ? void 0 : findContactWithIndex.contact, findContactWithIndex === null || findContactWithIndex === void 0 ? void 0 : findContactWithIndex.index).then(() => setShowModalOnAll(false));\n            },\n            onClose: () => setShowModalOnAll(false),\n            customClassNameButtonSecond: \"messenger__sidebar-profileControl-deleteProfile\",\n            children: /*#__PURE__*/_jsxDEV(\"div\", {\n              children: \"\\u0412\\u044B \\u0434\\u0435\\u0439\\u0441\\u0442\\u0432\\u0438\\u0442\\u0435\\u043B\\u044C\\u043D\\u043E \\u0445\\u043E\\u0442\\u0438\\u0442\\u0435 \\u0431\\u0435\\u0437\\u0432\\u043E\\u0437\\u0432\\u0440\\u0430\\u0442\\u043D\\u043E \\u0443\\u0434\\u0430\\u043B\\u0438\\u0442\\u044C \\u0437\\u0430\\u044F\\u0432\\u043A\\u0443?\"\n            }, void 0, false, {\n              fileName: _jsxFileName,\n              lineNumber: 63,\n              columnNumber: 29\n            }, this)\n          }, void 0, false, {\n            fileName: _jsxFileName,\n            lineNumber: 51,\n            columnNumber: 25\n          }, this)]\n        }, void 0, true, {\n          fileName: _jsxFileName,\n          lineNumber: 43,\n          columnNumber: 21\n        }, this);\n      }\n    } else {\n      return /*#__PURE__*/_jsxDEV(_Fragment, {}, void 0, false);\n    }\n  } else {\n    return /*#__PURE__*/_jsxDEV(_Fragment, {}, void 0, false);\n  }\n};\n_s(ContactControl, \"1uOOSHo8JHL/D4CKHAenl9/TZDU=\");\n_c = ContactControl;\nexport default _c2 = observer(ContactControl);\nvar _c, _c2;\n$RefreshReg$(_c, \"ContactControl\");\n$RefreshReg$(_c2, \"%default%\");","map":{"version":3,"names":["React","observer","Context","findContactOrReturnNull","Modal","ContactControl","props","store","useContext","findContactWithIndex","setFindContactWithIndex","useState","showModalOnAll","setShowModalOnAll","useEffect","selfProfile","getProfile","id","profile","getContacts","contact","index","status","fromUser","toUser","deleteContactFromAPI","then"],"sources":["/data/messenger.client/src/components/ContactControl/index.tsx"],"sourcesContent":["import React from 'react';\nimport {observer} from \"mobx-react-lite\";\nimport {Context} from \"../../index\";\nimport {findContactOrReturnNull} from \"../../utils/Contact\";\nimport {UserProfileProps} from \"../../models/props/UserProfileProps\";\nimport {ContactWithIndex} from \"../../models/props/ContactWithIndex\";\nimport {Modal} from \"../index\";\nimport './ContactControl.scss';\n\nconst ContactControl: React.FC<UserProfileProps> = (props) => {\n    const {store} = React.useContext(Context);\n    const [findContactWithIndex, setFindContactWithIndex] = React.useState<ContactWithIndex>();\n    const [showModalOnAll, setShowModalOnAll] = React.useState<boolean>(false);\n\n    React.useEffect(() => {\n        if (!props.selfProfile && store.getProfile().id !== props.profile.id) {\n            setFindContactWithIndex({\n                ...findContactWithIndex,\n                ...findContactOrReturnNull(props.profile, store.getProfile(), store.getContacts())\n            });\n        }\n    }, [store.getContacts(), props.profile]);\n\n    if (!props.selfProfile &&\n        store.getProfile().id !== props.profile.id\n    ) {\n        if (findContactWithIndex?.contact === null) {\n            return (\n                <div className=\"contact__control\">\n                    <button>Добавить в контакты</button>\n                </div>\n            );\n        } else if (findContactWithIndex?.contact && findContactWithIndex?.index) {\n            if (findContactWithIndex.contact.status) {\n                return (\n                    <div className=\"contact__control\">\n                        <span>У вас в контактах</span>\n                        <button>Удалить контакт</button>\n                    </div>\n                );\n            } else {\n                return (\n                    <div className=\"contact__control\">\n                        {findContactWithIndex.contact.fromUser.id === props.profile.id &&\n                            <span>Заявка отправлена</span>\n                        }\n                        {findContactWithIndex.contact.toUser.id === props.profile.id &&\n                            <button>Принять заявку</button>\n                        }\n                        <button>Удалить заявку</button>\n                        <Modal\n                            active={showModalOnAll}\n                            title={\"Удаление заявки\"}\n                            hasFunctionButtons={true}\n                            onSubmit={() => {\n                                store.deleteContactFromAPI(findContactWithIndex?.contact!, findContactWithIndex?.index!).then(() =>\n                                    setShowModalOnAll(false)\n                                );\n                            }}\n                            onClose={() => setShowModalOnAll(false)}\n                            customClassNameButtonSecond={\"messenger__sidebar-profileControl-deleteProfile\"}\n                        >\n                            <div>Вы действительно хотите безвозвратно удалить заявку?</div>\n                        </Modal>\n                    </div>\n                );\n            }\n        } else {\n            return (<></>);\n        }\n    } else {\n        return (<></>);\n    }\n}\n\nexport default observer(ContactControl);"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,QAAQ,QAAO,iBAAiB;AACxC,SAAQC,OAAO,QAAO,aAAa;AACnC,SAAQC,uBAAuB,QAAO,qBAAqB;AAG3D,SAAQC,KAAK,QAAO,UAAU;AAC9B,OAAO,uBAAuB;AAAC;AAAA;AAE/B,MAAMC,cAA0C,GAAIC,KAAK,IAAK;EAAA;EAC1D,MAAM;IAACC;EAAK,CAAC,GAAGP,KAAK,CAACQ,UAAU,CAACN,OAAO,CAAC;EACzC,MAAM,CAACO,oBAAoB,EAAEC,uBAAuB,CAAC,GAAGV,KAAK,CAACW,QAAQ,EAAoB;EAC1F,MAAM,CAACC,cAAc,EAAEC,iBAAiB,CAAC,GAAGb,KAAK,CAACW,QAAQ,CAAU,KAAK,CAAC;EAE1EX,KAAK,CAACc,SAAS,CAAC,MAAM;IAClB,IAAI,CAACR,KAAK,CAACS,WAAW,IAAIR,KAAK,CAACS,UAAU,EAAE,CAACC,EAAE,KAAKX,KAAK,CAACY,OAAO,CAACD,EAAE,EAAE;MAClEP,uBAAuB,CAAC;QACpB,GAAGD,oBAAoB;QACvB,GAAGN,uBAAuB,CAACG,KAAK,CAACY,OAAO,EAAEX,KAAK,CAACS,UAAU,EAAE,EAAET,KAAK,CAACY,WAAW,EAAE;MACrF,CAAC,CAAC;IACN;EACJ,CAAC,EAAE,CAACZ,KAAK,CAACY,WAAW,EAAE,EAAEb,KAAK,CAACY,OAAO,CAAC,CAAC;EAExC,IAAI,CAACZ,KAAK,CAACS,WAAW,IAClBR,KAAK,CAACS,UAAU,EAAE,CAACC,EAAE,KAAKX,KAAK,CAACY,OAAO,CAACD,EAAE,EAC5C;IACE,IAAI,CAAAR,oBAAoB,aAAp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